/********************************************
 * 功能说明: 
 * 模块名称: 
 * 系统名称: 
 * 软件版权: 北京银杉金服科技有限公司
 * 系统版本: 1.0.0
 * 开发人员: zhangfb
 * 开发时间: 2018/9/23 12:03
 * 审核人员: 
 * 相关文档: 
 * 修改记录: 修改日期 修改人员 修改说明
 *********************************************/
package com.hyacinth.entity;

import lombok.*;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**
 * 接口日志对象
 * @author zhangfb
 * @version 1.0.0.1
 * @since JDK 1.8
 */
@Document(indexName = "interlog", type = "InterfaceLog")
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name = "base_interface_log")
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class InterfaceLog extends BaseEntity{

    private static final long serialVersionUID = 1L;

    /** 请求url */
    @Column(
            name = "req_url",
            nullable = false,
            length = 32
    )
    @Field(type = FieldType.Text)
    private String reqUrl;
    /** 请求方法 */
    @Column(
            name = "method",
            nullable = false,
            length = 10
    )
    @Field(type = FieldType.Keyword)
    private String method;
    /** 用户编码 */
    @Column(
            name = "user_code",
            nullable = false,
            length = 32
    )
    @Field(type = FieldType.Keyword)
    private String userCode;
    /** 请求开始时间 yyyy-MM-dd HH:mm:ss.SSS*/
    @Column(
            name = "beg_time",
            nullable = false,
            length = 23
    )
    @Field(type = FieldType.Text, pattern = "yyyyMMddHHmmssSSS")
    private String begTime;
    /** 请求结束时间yyyyMMddHHmmssSSS*/
    @Column(
            name = "end_time",
            nullable = false,
            length = 23
    )
    @Field(type = FieldType.Text, pattern = "yyyyMMddHHmmssSSS")
    private String endTime;
    /** 耗费时长（单位毫秒） */
    @Column(
            name = "delay_time",
            nullable = false
    )
    @Field(type = FieldType.Long)
    private Long delayTime;
    /** 应用类型 */
    @Column(
            name = "app_type",
            nullable = false,
            length = 20
    )
    private String appType;
    /** 返回码 */
    @Column(
            name = "ret_code",
            nullable = false,
            length = 8
    )
    private Integer retCode;
    /** 返回信息 */
    @Column(
            name = "ret_msg",
            length = 512
    )
    private String retMsg;

    /** 接口请求 */
    @Column(
            name = "req_info",
            columnDefinition = " text"
    )
    private String reqInfo;
    /** 接口响应 */
    @Column(
            name = "resp_info",
            columnDefinition = " text"
    )
    private String respInfo;

    public InterfaceLog(Long id, String reqUrl, String method, String userCode, String begTime, String endTime, Long delayTime) {
        this.id = id;
        this.reqUrl = reqUrl;
        this.method = method;
        this.userCode = userCode;
        this.begTime = begTime;
        this.endTime = endTime;
        this.delayTime = delayTime;
    }
}
